package com.cy.pj.common.web;

import com.cy.pj.commmon.pojo.ResponseResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {
    private static  final Logger log = LoggerFactory.getLogger(GlobalExceptionHandler.class);
    @ExceptionHandler(RuntimeException.class)
    public ResponseResult doHandlerRunTimeExceptiom(RuntimeException e){
        log.error("exception is"+e.getMessage());
        return new ResponseResult(e);
        //pojo对象转换成json,有什么条件---提供get方法
        //map对象转换成json,json串中的key
    }
}
